<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActiveScaffold::Configurable</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActiveScaffold::Configurable</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/vendor/plugins/active_scaffold/lib/configurable_rb.html">
                vendor/plugins/active_scaffold/lib/configurable.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Exposes a <tt><a href="Configurable.html#M000161">configure</a></tt> method
that accepts a block and runs all contents of the block in two contexts, as
opposed to the normal one. First, everything gets evaluated as part of the
object including <a href="Configurable.html">Configurable</a>. Then, as a
failover, missing methods and variables are evaluated in the original
binding of the block.
</p>
<p>
Note that this only works with &quot;barewords&quot;. Constants, instance
variables, and class variables are not currently supported in both
contexts.
</p>
<p>
May add the given functionality at both the class and instance level. For
the former, use <tt>extend</tt>, and for the latter, use <tt>include</tt>.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000161">configure</a>&nbsp;&nbsp;
      <a href="#M000162">method_missing</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000161" class="method-detail">
        <a name="M000161"></a>

        <div class="method-heading">
          <a href="#M000161" class="method-signature">
          <span class="method-name">configure</span><span class="method-args">(&amp;configuration_block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000161-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000161-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/configurable.rb, line 8</span>
 8:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">configuration_block</span>)
 9:       <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">configuration_block</span>
10:       <span class="ruby-ivar">@configuration_binding</span> = <span class="ruby-identifier">configuration_block</span>.<span class="ruby-identifier">binding</span>
11:       <span class="ruby-identifier">ret</span> = <span class="ruby-identifier">instance_eval</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">configuration_block</span>
12:       <span class="ruby-ivar">@configuration_binding</span> = <span class="ruby-keyword kw">nil</span>
13:       <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">ret</span>
14:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000162" class="method-detail">
        <a name="M000162"></a>

        <div class="method-heading">
          <a href="#M000162" class="method-signature">
          <span class="method-name">method_missing</span><span class="method-args">(name, *args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
this method will surely need tweaking. for example, i&#8216;m not sure if
it should call super before or after it tries to eval with the binding.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000162-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000162-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/configurable.rb, line 17</span>
17:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
18:       <span class="ruby-keyword kw">begin</span>
19:         <span class="ruby-keyword kw">super</span>
20:       <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">NoMethodError</span>, <span class="ruby-constant">NameError</span>
21:         <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@configuration_binding</span>.<span class="ruby-identifier">nil?</span>
22:           <span class="ruby-identifier">raise</span> <span class="ruby-identifier">$!</span>
23:         <span class="ruby-keyword kw">else</span>
24:           <span class="ruby-identifier">eval</span>(<span class="ruby-value str">&quot;self&quot;</span>, <span class="ruby-ivar">@configuration_binding</span>).<span class="ruby-identifier">send</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
25:         <span class="ruby-keyword kw">end</span>
26:       <span class="ruby-keyword kw">end</span>
27:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>